package com.sxt.springsecuritytest2.controller; /*
 *
 * @Description todo
 * @author qqg
 * @date $date$
 * @param $params$
 * @return $return$
 **/

import com.sxt.springsecuritytest2.mapper.SysRoleMapper;
import com.sxt.springsecuritytest2.service.SysUserService;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ProductController {

    @Reference
    private SysUserService sysUserService;

    @Reference
    private SysRoleMapper sysRoleMapper;

    @ResponseBody
    @RequestMapping("/product")
    @Secured("ROLE_USER")
    public String product(){
        return "success";
    }

    @ResponseBody
    @RequestMapping("/info")
    @Secured("ROLE_ADMIN")
    public String UserInfo(){
//        UserDetails admin = sysUserService.loadUserByUsername("admin");
//        List<SysRole> byUid = sysRoleMapper.findByUid(admin.getId());
//        admin.setRoles(byUid);
        return "info page";
    }
}
